<%@page import="org.springframework.security.core.context.SecurityContextHolder"%>
<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="org.apache.commons.lang.time.DateFormatUtils"%>
<%@page import="org.springframework.util.CollectionUtils"%>
<%@page import="java.util.Collection"%>
<%@ include file="../common/common_include.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%

String userName = SecurityContextHolder.getContext().getAuthentication().getName();
String nowDate = DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss");
TblSiteVedio video = (TblSiteVedio)request.getAttribute("video");
%>


<div>
		<form id="videoFORM" name="form" target="coreIframe"
			action="<%=request.getContextPath()%>/site/doVideoEdit" method="post" enctype="multipart/form-data">
			<div class="breadcrumb">
				<div class="bcIcon"></div>
				<ul class="bcNav">

					<li>增加视频</li>
				</ul>
			</div>
			<%
				String id = EncrypTool.encode(video.getId().intValue());
			%>
<input type="hidden" name="id" value="<%=id %>" >
			<table class="formTable">

				<tr>
					<td class="tdTitle">发布时间：</td>
					<td><input class="inputText xs" type="text" name="publicTime"
						 value="<%=nowDate%>"
						onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" /></td>
				</tr>
				<tr>
					<td class="tdTitle">发布人：</td>
					<td><input class="inputText xs" type="text" name="publicMan"
						 placeholder="请输入发布人" value="<%=video.getAdduser()%>"  /></td>
				</tr>
				<tr>
					<td class="tdTitle">视频名称：</td>
					<td><input class="inputText s" type="text" name="videoTitle" value="<%=video.getName() %>"
						 placeholder="请输入视频名称" /><span class="errorTipWrap" id="errorTip_videoTitle"></span></td>
				</tr>
			
				<tr>
					<td class="tdTitle">视频描述：</td>
					<td class="" colspan="2">
						<div style="padding-top: 10px; padding-bottom: 10px;">
							<textarea id="content" name="videoDesc"
								style="width: 700px; height: 200px; visibility: hidden;"><%=video.getDescribe() %></textarea>
						</div>
						<span class="errorTipWrap" id="errorTip_videoDesc"></span>
					</td>
				</tr>
				<tr>
					<td class="tdTitle">封面图片：</td>
					<td><input type="file" name="imgFile" id="up">
						<span style="color:#ff5a00">尺寸要求：宽245px 高165px</span>
						<div><img id="imgPreview" width="70" height="50" src="<%=request.getContextPath() %>/imagextra/<%=video.getPicture()%>" /></div>
					</td>
				</tr>
				
				<tr>	
					<td class="tdTitle">视频：</td>
					<td>
						<input type="file" id="multipartFile">
						<span class="uploadResultLabel" id="uploadResultLabel" style="display: inline-block;"><%=video.getDir()%></span>
						<div>
							<span class="uploadTip">只能上传mp4,f4v,flv格式的文件</span>
						</div>
						<input type="hidden" name="tempFileId" value="">
					</td>
				</tr>
				<tr>
					<td class="tdTitle"></td>
					<td>
						<div>
							<input class="input-btn-microsoft" type="submit" value="提交" id="click_btn">
							<a class="a-btn-microsoft"
								href="javascript:XF.Site.requestUrl('/site/videoList')">取消</a>
						</div>
					</td>
				</tr>
			</table>
		</form>
</div>
<iframe name="coreIframe" style="display: none"></iframe>
<script type="text/javascript">
	$(function() {
		XF.createKindEditor("content");
		$("input[name=videoTitle]").focus();
		_uploadFile("multipartFile","<%=request.getSession().getId()%>");
	    function _uploadFile(id,sid){
			$("#"+id).uploadify({
		        auto: true,
		        multi:false,
		        fileExt:'*.mp4;*.swf;*.flv',
		        uploader: global.contextPath + "/servlet/upload?jsessionid="+sid,
		        swf: global.contextPath + '/js/jplugin/uploadify/uploadify.swf',
		        onUploadSuccess:function(file, data, response){
		        	var fileName = file.name;
		        	var data = JSON.parse(data);
		        	if(data['status']=='0'){
		        		$("#uploadResultLabel").html(fileName);
		        		$("input[name=tempFileId]").val(data['fileId']);
		        		var nameEle = $("input[name=name]");
		        		if(nameEle.val()==""){
		        			nameEle.val(fileName);
		        		}
		        	}else if(data['status']=='1'){
		        		var s = "上传失败："+data['errorMessage'];
		        		$("#uploadResultLabel").html("<span style='color:#ff0000'>"+s+"</span>");
		        	}
		        }
		    });
	    };
	    
	}); 
</script>
</html>